
<template>
  <div class="own-space">
    <!-- class="demo-drawer-footer-drivle" -->
    <div>
      <Card class="own-space-new">
        <div class="own-wrap">
          <div style="width: 240px">
            <Menu
              :active-name="activeName"
              theme="light"
              @on-select="changeMenu"
            >
              <MenuItem name="基本信息">基本信息</MenuItem>
              <MenuItem name="安全设置">安全设置</MenuItem>
              <!-- <MenuItem name="第三方账号绑定">第三方账号绑定</MenuItem> -->
              <MenuItem v-show="personalAuthentication" name="个人认证">
                <div>
                  个人认证
                  <span style="margin-left: 74px">
                    <Tag
                      :color="
                        userCompanyInfoData.companyStatus == 0
                          ? 'red'
                          : userCompanyInfoData.companyStatus == 1
                          ? 'green'
                          : userCompanyInfoData.companyStatus == 2
                          ? 'blue'
                          : userCompanyInfoData.companyStatus == 3
                          ? 'red'
                          : 'red'
                      "
                    >
                      {{
                        userCompanyInfoData.companyStatus == 0
                          ? "未认证"
                          : userCompanyInfoData.companyStatus == 1
                          ? "已认证"
                          : userCompanyInfoData.companyStatus == 2
                          ? "审核中"
                          : userCompanyInfoData.companyStatus == 3
                          ? "已过期"
                          : "未认证"
                      }}
                    </Tag></span
                  >
                </div>
              </MenuItem>
              <MenuItem v-show="enterpriseCrtification" name="企业认证">
                <div style="display: flex">
                  <div>企业认证</div>
                  <div style="margin-left: 23px; margin-top: -2px">
                    <span>
                      <Tag
                        :color="
                          userCompanyInfoData.companyStatus == 0
                            ? 'red'
                            : userCompanyInfoData.companyStatus == 1
                            ? 'green'
                            : userCompanyInfoData.companyStatus == 2
                            ? 'blue'
                            : userCompanyInfoData.companyStatus == 3
                            ? 'red'
                            : 'red'
                        "
                      >
                        {{
                          userCompanyInfoData.companyStatus == 0
                            ? "未认证"
                            : userCompanyInfoData.companyStatus == 1
                            ? "已认证"
                            : userCompanyInfoData.companyStatus == 2
                            ? "审核中"
                            : userCompanyInfoData.companyStatus == 3
                            ? "已过期"
                            : "未认证"
                        }}
                      </Tag>
                    </span>
                  </div>
                </div>
              </MenuItem>
              <MenuItem name="消息通知">消息通知</MenuItem>
            </Menu>
          </div>
          <div style="padding: 8px 40px; width: 100%">
            <div class="title-accon">
              {{
                currMenu == "个人认证"
                  ? ""
                  : currMenu == "企业认证"
                  ? ""
                  : currMenu
              }}
            </div>
            <div>
              <div v-show="currMenu == '基本信息'" >
                <Form
                  ref="userForm"
                  :model="userForm"
                  :label-width="90"
                  label-position="left"
                >
                  <FormItem label="登录账号：" prop="username">{{
                    userForm.username
                  }}</FormItem>
                  <FormItem label="用户头像：">
                    <upload-pic-thumb
                      v-model="userForm.avatar"
                      :multiple="false"
                    ></upload-pic-thumb>
                  </FormItem>
                  <FormItem label="用户名：" prop="nickName">
                    {{ userForm.nickName }}
                    <!-- <Input v-model="userForm.nickName" style="width: 300px" /> -->
                  </FormItem>
                  <!-- <FormItem label="性别：">
                  <RadioGroup v-model="userForm.sex">
                    <Radio
                      v-for="(item, i) in dictSex"
                      :key="i"
                      :label="item.value"
                      >{{ item.title }}</Radio
                    >
                  </RadioGroup>
                </FormItem> -->
                  <!-- <FormItem label="生日：">
                  <DatePicker
                    v-model="userForm.birth"
                    @on-change="changeBirth"
                    style="width: 300px"
                    type="date"
                  ></DatePicker>
                </FormItem> -->
                  <FormItem label="收货地址：">
                    <Cascader
                      style="width: 300px"
                      v-model="userForm.addressSelection"
                      :data="AddressData"
                      :load-data="addLoadingProvinceloadData"
                      @on-change="getStartArea"
                      clearable
                    ></Cascader>
                  </FormItem>
                  <FormItem label="详细地址：" prop="street">
                    <Input v-model="userForm.street" style="width: 300px" />
                  </FormItem>
                  <!-- <FormItem label="个人简介：" prop="description">
                  <Input
                    v-model="userForm.description"
                    type="textarea"
                    style="width: 300px"
                    :autosize="{ minRows: 3, maxRows: 5 }"
                    placeholder="个人简介"
                  ></Input>
                </FormItem> -->
                  <FormItem label="所属部门：">
                    <span>{{
                      userForm.departmentTitle == "" ||
                      userForm.departmentTitle == null
                        ? "无"
                        : userForm.departmentTitle
                    }}</span>
                  </FormItem>
                  <!-- <FormItem label="用户类型：">
                  <span>{{ userForm.typeTxt }}</span>
                </FormItem> -->
                  <FormItem>
                    <Button
                      type="primary"
                      style="width: 100px; margin-right: 5px"
                      :loading="saveLoading"
                      @click="saveEdit"
                      >保存</Button
                    >
                  </FormItem>
                </Form>
              </div>
              <div v-show="currMenu == '安全设置'"  class="safe">

                <div class="item">
                  <div>
                    <div class="title-accon">绑定手机</div>
                    <div class="desc">
                      <span v-if="userForm.mobile"
                        >已绑定手机：{{ userForm.mobile }}</span
                      >
                      <span v-else>未绑定手机号</span>
                    </div>
                  </div>
                  <div>
                    <a @click="showChangeMobile">修改</a>
                  </div>
                </div>
              </div>
              <div>
                <div v-show="currMenu == '企业认证'" class="safe">
                  <div></div>
                  <div>
                    <Form
                      :model="companyLicenseForm"
                      ref="companyLicenseForm"
                      :rules="companyForm"
                      :label-width="145"
                      inline
                    >
                      <div style="display: flex">
                        <div
                          style="
                            width: 682px;
                            margin-left: -33px;
                            margin-top: 20px;
                          "
                        >
                          <p class="titles">企业信息</p>
                          <div style="margin-left: -19px">
                            <div style="display: flex">
                              <div>
                                <FormItem label="公司名称" prop="companyName">
                                  <Input
                                    :disabled="
                                      userCompanyInfoData.companyStatus == 1 ||
                                      userCompanyInfoData.companyStatus == 2
                                    "
                                    placeholder="请输入公司名称"
                                    style="width: 195px"
                                    v-model="companyLicenseForm.companyName"
                                    clearable
                                  />
                                </FormItem>
                              </div>
                              <div style="margin-left: 53px">
                                <FormItem
                                  label="统一社会信用代码"
                                  prop="certNo"
                                >
                                  <Input
                                    :disabled="
                                      userCompanyInfoData.companyStatus == 1 ||
                                      userCompanyInfoData.companyStatus == 2
                                    "
                                    placeholder="请输入统一社会信用代码"
                                    v-model="companyLicenseForm.certNo"
                                    style="width: 140px"
                                  />
                                </FormItem>
                              </div>
                            </div>
                            <FormItem label="公司类型">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入公司类型"
                                style="width: 195px"
                                v-model="companyLicenseForm.type"
                                clearable
                              />
                            </FormItem>
                            <FormItem label="通讯地址" prop="street">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入通讯地址"
                                style="width: 195px"
                                v-model="companyLicenseForm.street"
                                clearable
                              />
                            </FormItem>
                            <div style="display: flex">
                              <div style="margin-left: 14px">
                                <FormItem
                                  label="法定代表人"
                                  prop="companyUserName"
                                >
                                  <Input
                                    :disabled="
                                      userCompanyInfoData.companyStatus == 1 ||
                                      userCompanyInfoData.companyStatus == 2
                                    "
                                    style="width: 180px"
                                    placeholder="请输入法定代表人"
                                    v-model="companyLicenseForm.companyUserName"
                                    clearable
                                  />
                                </FormItem>
                              </div>
                              <div>
                                <FormItem label="注册电话">
                                  <Input
                                    :disabled="
                                      userCompanyInfoData.companyStatus == 1 ||
                                      userCompanyInfoData.companyStatus == 2
                                    "
                                    placeholder="请输入注册电话"
                                    style="width: 195px"
                                    v-model="companyLicenseForm.companyPhone"
                                    clearable
                                  />
                                </FormItem>
                              </div>
                            </div>
                            <FormItem label="开户银行">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入开户银行"
                                style="width: 195px"
                                v-model="companyLicenseForm.bankName"
                                clearable
                              />
                            </FormItem>
                            <FormItem label="银行账号">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入银行账号"
                                style="width: 195px"
                                v-model="companyLicenseForm.bankCode"
                                clearable
                              />
                            </FormItem>
                          </div>
                          <Row style="margin-left: 44px">
                            <Col span="8">
                              <div
                                v-if="companyPicFileUrl"
                                style="
                                  width: 148px;
                                  height: 92px;
                                  line-height: 75px;
                                  margin-bottom: 7px;
                                "
                              >
                                <div class="demo-upload-list-company">
                                  <img
                                    v-if="companyPicFileUrl != ''"
                                    style="width: 58px"
                                    height="100px"
                                    :src="companyPicFileUrl"
                                  />
                                  <img
                                    style="width: 58px"
                                    height="100px"
                                    src="@/assets/vehicleAtes/owner3.png"
                                  />
                                  <div
                                    v-if="companyPicFileUrl != ''"
                                    class="demo-upload-list-company-cover"
                                  >
                                    <Icon
                                      type="ios-eye-outline"
                                      @click.native="showPic(companyPicFileUrl)"
                                    ></Icon>
                                    <Icon
                                      v-if="
                                        userCompanyInfoData.companyStatus == 0
                                      "
                                      type="ios-trash-outline"
                                      @click.stop="
                                        handleRemove(companyPicFileUrl, 1)
                                      "
                                    ></Icon>
                                  </div>
                                </div>
                              </div>
                              <Upload
                                v-else
                                class="Upload-border"
                                v-show="userCompanyInfoData.companyStatus == 0"
                                :on-progress="BusinessLicen"
                                :beforeUpload="beforeUpload"
                                ref="companyUpload"
                                :show-upload-list="false"
                                :on-success="handleSuccess"
                                :format="['jpg', 'jpeg', 'png']"
                                :on-format-error="handleFormatError"
                                :headers="header"
                                :data="{
                                  fileType: 'IDCARD_FONT_PIC',
                                  userId: userCompanyInfoData.userId,
                                }"
                                type="drag"
                                :action="upLoadCompanyLicense"
                                style="display: inline-block"
                              >
                                <div
                                  style="
                                    width: 148px;
                                    height: 92px;
                                    line-height: 75px;
                                  "
                                >
                                  <div class="demo-upload-list-company">
                                    <img
                                      v-if="companyPicFileUrl != ''"
                                      style="width: 148px"
                                      height="100px"
                                      :src="companyPicFileUrl"
                                    />
                                    <img
                                      style="width: 148px"
                                      height="100px"
                                      src="@/assets/vehicleAtes/owner3.png"
                                    />
                                    <div
                                      v-if="companyPicFileUrl != ''"
                                      class="demo-upload-list-company-cover"
                                    >
                                      <Icon
                                        type="ios-eye-outline"
                                        @click.native="
                                          showPic(companyPicFileUrl)
                                        "
                                      ></Icon>
                                      <Icon
                                        type="ios-trash-outline"
                                        @click.stop="
                                          handleRemove(companyPicFileUrl, 1)
                                        "
                                      ></Icon>
                                    </div>
                                  </div>
                                  <!-- <Icon type="ios-camera" size="20"></Icon> -->
                                </div>
                              </Upload>
                              <div class="demo-uploadcss-compny">
                                <template>
                                  <Progress
                                    v-if="progressBusinessLicen"
                                    text-inside
                                    :percent="load"
                                    :stroke-width="3"
                                  ></Progress>
                                </template>
                              </div>
                              <div style="margin-top: 15px" class="check">
                                <span class="check_font">营业执照</span>
                              </div>
                            </Col>
                          </Row>
                        </div>
                        <div style="width: 682px; margin-top: 20px">
                          <p class="titles">联系人信息</p>
                          <div style="margin-left: -44px">
                            <FormItem label="姓名" prop="contactName">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                style="width: 219px"
                                placeholder="请输入姓名"
                                v-model="companyLicenseForm.contactName"
                              />
                            </FormItem>
                            <FormItem label="联系电话" prop="contactPhone">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入联系电话"
                                v-model="companyLicenseForm.contactPhone"
                                clearable
                                style="width: 190px"
                              />
                            </FormItem>
                          </div>
                          <div>
                            <FormItem label="身份有效期" prop="contactEndDate">
                              <DatePicker
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                type="date"
                                style="width: 175px"
                                format="yyyyMMdd"
                                placeholder="请选择身份有效期"
                                :value="companyLicenseForm.contactEndDate"
                                @on-change="companyLicenseFormEndDate"
                              ></DatePicker>
                            </FormItem>
                            <FormItem label="身份证号" prop="contactNum">
                              <Input
                                :disabled="
                                  userCompanyInfoData.companyStatus == 1 ||
                                  userCompanyInfoData.companyStatus == 2
                                "
                                placeholder="请输入身份证号"
                                style="width: 190px"
                                v-model="companyLicenseForm.contactNum"
                                clearable
                              />
                            </FormItem>
                          </div>
                          <Row style="margin-left: 44px; margin-top: 40px">
                            <Col span="8">
                              <div
                                v-if="enterpriseIdCardFontPicFileUrl"
                                style="
                                  width: 148px;
                                  height: 92px;
                                  line-height: 75px;
                                  margin-bottom: 7px;
                                "
                              >
                                <div class="demo-upload-list-company">
                                  <img
                                    v-if="enterpriseIdCardFontPicFileUrl != ''"
                                    style="width: 58px"
                                    height="100px"
                                    :src="enterpriseIdCardFontPicFileUrl"
                                  />
                                  <img
                                    style="width: 58px"
                                    height="100px"
                                    src="@/assets/vehicleAtes/owner1.png"
                                  />
                                  <div
                                    v-if="enterpriseIdCardFontPicFileUrl != ''"
                                    class="demo-upload-list-company-cover"
                                  >
                                    <Icon
                                      type="ios-eye-outline"
                                      @click.native="
                                        showPic(enterpriseIdCardFontPicFileUrl)
                                      "
                                    ></Icon>
                                    <Icon
                                      v-if="
                                        userCompanyInfoData.companyStatus == 0
                                      "
                                      type="ios-trash-outline"
                                      @click.stop="
                                        handleRemove(
                                          enterpriseIdCardFontPicFileUrl,
                                          2
                                        )
                                      "
                                    ></Icon>
                                  </div>
                                </div>
                              </div>
                              <Upload
                                class="Upload-border"
                                v-else
                                v-show="userCompanyInfoData.companyStatus == 0"
                                :on-progress="enterprIseidCard"
                                :beforeUpload="beforeUpload"
                                ref="companyUpload"
                                :show-upload-list="false"
                                :on-success="enterpriseID"
                                :format="['jpg', 'jpeg', 'png']"
                                :on-format-error="handleFormatError"
                                :headers="header"
                                :data="{
                                  fileType: 'IDCARD_FONT_PIC',
                                  userId: userCompanyInfoData.userId,
                                }"
                                type="drag"
                                :action="uploadIdCardPic"
                                style="display: inline-block"
                              >
                                <div
                                  style="
                                    width: 148px;
                                    height: 92px;
                                    line-height: 75px;
                                  "
                                >
                                  <div class="demo-upload-list-company">
                                    <img
                                      v-if="
                                        enterpriseIdCardFontPicFileUrl != ''
                                      "
                                      style="width: 58px"
                                      height="100px"
                                      :src="enterpriseIdCardFontPicFileUrl"
                                    />
                                    <img
                                      style="width: 58px"
                                      height="100px"
                                      src="@/assets/vehicleAtes/owner1.png"
                                    />
                                    <div
                                      v-if="
                                        enterpriseIdCardFontPicFileUrl != ''
                                      "
                                      class="demo-upload-list-company-cover"
                                    >
                                      <Icon
                                        type="ios-eye-outline"
                                        @click.native="
                                          showPic(
                                            enterpriseIdCardFontPicFileUrl
                                          )
                                        "
                                      ></Icon>
                                      <Icon
                                        type="ios-trash-outline"
                                        @click.stop="
                                          handleRemove(
                                            enterpriseIdCardFontPicFileUrl,
                                            2
                                          )
                                        "
                                      ></Icon>
                                    </div>
                                  </div>
                                </div>
                              </Upload>
                              <div class="demo-uploadcss-compny">
                                <template>
                                  <Progress
                                    v-if="progressFront"
                                    text-inside
                                    :percent="load"
                                    :stroke-width="3"
                                  ></Progress>
                                </template>
                              </div>
                              <div style="margin-top: 15px" class="check">
                                <span class="check_font">身份证正面</span>
                              </div>
                            </Col>
                            <Col span="8">
                              <div
                                v-if="enterprIseidCardBackPicFileUrl"
                                style="
                                  width: 148px;
                                  height: 92px;
                                  line-height: 75px;
                                  margin-bottom: 7px;
                                "
                              >
                                <div class="demo-upload-list-company">
                                  <img
                                    v-if="enterprIseidCardBackPicFileUrl != ''"
                                    style="width: 58px"
                                    height="100px"
                                    :src="enterprIseidCardBackPicFileUrl"
                                  />
                                  <img
                                    style="width: 58px"
                                    height="100px"
                                    src="@/assets/vehicleAtes/owner2.png"
                                  />
                                  <div
                                    v-if="enterprIseidCardBackPicFileUrl != ''"
                                    class="demo-upload-list-company-cover"
                                  >
                                    <Icon
                                      type="ios-eye-outline"
                                      @click.native="
                                        showPic(enterprIseidCardBackPicFileUrl)
                                      "
                                    ></Icon>
                                    <Icon
                                      v-if="
                                        userCompanyInfoData.companyStatus == 0
                                      "
                                      type="ios-trash-outline"
                                      @click.stop="
                                        handleRemove(
                                          enterprIseidCardBackPicFileUrl,
                                          3
                                        )
                                      "
                                    ></Icon>
                                  </div>
                                </div>
                              </div>
                              <Upload
                                class="Upload-border"
                                v-else
                                v-show="userCompanyInfoData.companyStatus == 0"
                                :on-progress="enterprIseidCardf"
                                :beforeUpload="beforeUpload"
                                ref="companyUpload"
                                :show-upload-list="false"
                                :on-success="reverseIDCard"
                                :format="['jpg', 'jpeg', 'png']"
                                :on-format-error="handleFormatError"
                                :headers="header"
                                :data="{
                                  fileType: 'IDCARD_BACK_PIC',
                                  userId: userCompanyInfoData.userId,
                                }"
                                type="drag"
                                :action="uploadIdCardPic"
                                style="display: inline-block"
                              >
                                <div
                                  style="
                                    width: 148px;
                                    height: 92px;
                                    line-height: 75px;
                                  "
                                >
                                  <div class="demo-upload-list-company">
                                    <img
                                      v-if="
                                        enterprIseidCardBackPicFileUrl != ''
                                      "
                                      style="width: 58px"
                                      height="100px"
                                      :src="enterprIseidCardBackPicFileUrl"
                                    />
                                    <img
                                      style="width: 58px"
                                      height="100px"
                                      src="@/assets/vehicleAtes/owner2.png"
                                    />
                                    <div
                                      v-if="
                                        enterprIseidCardBackPicFileUrl != ''
                                      "
                                      class="demo-upload-list-company-cover"
                                    >
                                      <Icon
                                        type="ios-eye-outline"
                                        @click.native="
                                          showPic(
                                            enterprIseidCardBackPicFileUrl
                                          )
                                        "
                                      ></Icon>
                                      <Icon
                                        type="ios-trash-outline"
                                        @click.stop="
                                          handleRemove(
                                            enterprIseidCardBackPicFileUrl,
                                            3
                                          )
                                        "
                                      ></Icon>
                                    </div>
                                  </div>
                                </div>
                              </Upload>
                              <div class="demo-uploadcss-compny">
                                <template>
                                  <Progress
                                    v-if="progressReverse"
                                    text-inside
                                    :percent="load"
                                    :stroke-width="3"
                                  ></Progress>
                                </template>
                              </div>
                              <div style="margin-top: 15px" class="check">
                                <span class="check_font">身份证反面</span>
                              </div>
                            </Col>
                          </Row>
                        </div>
                      </div>
                      <div class="line"></div>
                      <div class="company-bottom"></div>
                      <Row>
                        <Col>
                          <Button
                            v-show="userCompanyInfoData.companyStatus == 0"
                            style="margin-left: 6px; margin-top: 22px"
                            type="warning"
                            @click="enterpriseCertification"
                            :loading="loadinLicenseInfo"
                            >提交资料</Button
                          >
                        </Col>
                      </Row>
                      <!-- <div style="display: flex; margin-top: 20px">
                        <div style="margin-left: 10px">
                          <Checkbox v-model="saveLogins" size="large">
                            <span style="font-size: 12px; color: eee">
                              我已阅读并同意</span
                            >
                          </Checkbox>
                        </div>
                        <div class="agreement1" @click="useRegistration">
                          《平台认证协议》
                        </div>
                      </div> -->
                    </Form>
                  </div>
                </div>
              </div>
              <div v-show="currMenu == '消息通知'" class="safe">
                <div class="item">
                  <div>
                    <div class="title-accon">系统消息</div>
                    <div class="desc">系统消息将以站内信的形式通知</div>
                  </div>
                  <div>
                    <i-switch
                      v-model="messageOpen"
                      @on-change="changeMessage"
                      :true-value="1"
                      :false-value="0"
                    >
                      <span slot="open">开</span>
                      <span slot="close">关</span>
                    </i-switch>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </Card>
      <Spin size="large" fix v-if="spinShow"></Spin>
    </div>
    <!-- 修改密码 -->
    <Modal
      title="修改密码"
      v-model="editPasswordVisible"
      :closable="false"
      :mask-closable="false"
      :width="500"
    >
      <div>
        <Form
          ref="editPasswordForm"
          :model="editPasswordForm"
          :label-width="100"
          label-position="right"
          :rules="passwordValidate"
          style="width: 450px"
        >
          <FormItem label="原密码" prop="oldPass">
            <Input
              password
              type="password"
              v-model="editPasswordForm.oldPass"
              placeholder="请输入现在使用的密码"
            ></Input>
          </FormItem>
          <FormItem label="新密码" prop="newPass">
            <SetPassword
              v-model="editPasswordForm.newPass"
              @on-change="changeInputPass"
            />
          </FormItem>
          <FormItem label="确认新密码" prop="rePass">
            <Input
              password
              type="password"
              v-model="editPasswordForm.rePass"
              placeholder="请再次输入新密码"
            ></Input>
          </FormItem>
          <FormItem> </FormItem>
        </Form>
      </div>
      <div slot="footer">
        <Button
          type="primary"
          style="width: 100px; margin-right: 5px"
          :loading="savePassLoading"
          @click="saveEditPass"
          >保存</Button
        >
        <Button @click="editPasswordVisible = false">取消</Button>
      </div>
    </Modal>
    <!-- 修改手机号 -->
    <Modal
      title="修改手机号"
      v-model="editMobileVisible"
      :closable="false"
      :mask-closable="false"
      :width="500"
    >
      <Form
        ref="mobileEditForm"
        :model="mobileEditForm"
        :label-width="80"
        :rules="mobileEditValidate"
      >
        <FormItem label="新手机号" prop="mobile">
          <Input
            v-model="mobileEditForm.mobile"
            @on-change="hasChangePhone"
            placeholder="请输入新手机号"
          />
        </FormItem>
        <FormItem label="图片验证" prop="imgCode">
          <Row
            type="flex"
            justify="space-between"
            style="align-items: center; overflow: hidden"
          >
            <Input
              style="width: 71%"
              v-model="mobileEditForm.imgCode"
              clearable
              placeholder="请输入图片验证码"
              :maxlength="10"
              class="input-verify"
            />
            <div class="code-image" style="position: relative; font-size: 12px">
              <Spin v-if="loadingCaptcha" fix></Spin>
              <img
                :src="captchaImg"
                @click="getCaptchaImg"
                alt="加载验证码失败"
                style="width: 102px; cursor: pointer; display: block"
              />
            </div>
          </Row>
        </FormItem>
        <FormItem label="验证码" prop="code">
          <Row type="flex" justify="space-between">
            <Input
              v-model="mobileEditForm.code"
              placeholder="请输入您收到的短信验证码"
              style="width: 71%"
            />
            <span>
              <CountDownButton
                ref="countDownMobile"
                @on-click="sendEditMobileCode"
                :disabled="canSendMobileCode"
                :autoCountDown="false"
                :loading="sending"
                :text="getSms"
              />
            </span>
          </Row>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="cancelInputCodeBox">取消</Button>
        <Button
          type="primary"
          :loading="checkCodeLoading"
          @click="submitEditMobile"
          >提交</Button
        >
      </div>
    </Modal>

    <Modal
      title="修改邮箱"
      v-model="editEmailVisible"
      :closable="false"
      :mask-closable="false"
      :width="500"
    >
      <Form
        ref="emailEditForm"
        :model="emailEditForm"
        :label-width="100"
        :rules="emailEditValidate"
      >
        <FormItem label="新邮箱地址" prop="email">
          <Input
            v-model="emailEditForm.email"
            @on-change="hasChangeEmail"
            placeholder="请输入新邮箱地址"
          ></Input>
        </FormItem>
        <FormItem label="验证码" prop="code" :error="codeError">
          <Row type="flex" justify="space-between">
            <Input
              v-model="emailEditForm.code"
              placeholder="请输入您收到的邮件中的验证码"
              style="width: 250px"
            />
            <CountDownButton
              ref="countDownEmail"
              @on-click="sendVerifyEmail"
              :disabled="canSendEditEmail"
              :autoCountDown="false"
              :loading="sending"
              :text="getSms"
            />
          </Row>
        </FormItem>
      </Form>
      <div slot="footer">
        <Button type="text" @click="cancelEditEmail">取消</Button>
        <Button
          type="primary"
          :loading="editEmailLoading"
          @click="submitEditEmail"
          >提交</Button
        >
      </div>
    </Modal>
    <!-- 支付密码 -->
    <Modal
      :title="paymentPasswordTitle"
      v-model="paymentPasswordVisible"
      :closable="false"
      :mask-closable="false"
      :width="500"
    >
      <div>
        <Form
          ref="paymentPasswordForm"
          :model="paymentPasswordForm"
          :label-width="100"
          label-position="right"
          :rules="paymentPasswordRules"
          style="width: 450px"
        >
          <FormItem label="登录账号" prop="mobile">
            <Input
              disabled
              v-model="paymentPasswordForm.mobile"
              placeholder="请输入登录账号"
            ></Input>
          </FormItem>
          <div
            v-if="
              paymentPasswordTitle == '设置支付密码' ||
              paymentPasswordTitle == '重置支付密码'
            "
          >
            <FormItem label="身份证号" prop="mobile">
              <Input
                v-model="paymentPasswordForm.idNum"
                placeholder="请输入实名的身份证号"
              ></Input>
            </FormItem>
          </div>
          <div v-if="this.paymentPasswordTitle != '修改支付密码'">
            <FormItem :label="labelPassword" prop="password">
              <Input
                password
                type="password"
                :placeholder="placeholderPassword"
                v-model="paymentPasswordForm.password"
              />
            </FormItem>
            <FormItem :label="confLabelPassword" prop="confirmpassword">
              <Input
                password
                type="password"
                v-model="paymentPasswordForm.confirmpassword"
                :placeholder="conLaceholderPassword"
              ></Input>
            </FormItem>
          </div>

          <div v-if="this.paymentPasswordTitle == '修改支付密码'">
            <FormItem label="当前密码" prop="password">
              <Input
                password
                type="password"
                placeholder="请输入当前支付密码"
                v-model="paymentPasswordForm.password"
              />
            </FormItem>
            <FormItem label="新密码" prop="confirmpassword">
              <Input
                password
                type="password"
                v-model="paymentPasswordForm.confirmpassword"
                placeholder="请输入新的支付密码"
              ></Input>
            </FormItem>
          </div>
          <FormItem label="验证码">
            <div slot="label" class="check">验证码</div>
            <div style="display: flex">
              <div>
                <Input
                  style="width: 120%"
                  v-model="paymentPasswordForm.code"
                  placeholder="验证码"
                ></Input>
              </div>
              <div v-if="butVerificationCode" style="margin-left: 60px">
                <CountDownButton
                  ref="countDown"
                  @on-click="checkVaptcha"
                  :autoCountDown="false"
                  size="default"
                  type="primary"
                  :loading="sending"
                  :text="getSms"
                />
              </div>
            </div>
          </FormItem>
        </Form>
      </div>
      <div slot="footer">
        <Button
          type="primary"
          style="margin-right: 5px"
          :loading="preservationLoading"
          @click="preservationPassword"
          >{{ paymentPasswordBut }}</Button
        >
        <Button @click="paymentPasswordVisible = false">取消</Button>
      </div>
    </Modal>
    <!-- 用户认证弹框 -->
    <!-- <Modal
      :closable="false"
      :mask-closable="false"
      class="Modalcss"
      v-model="selectUserType"
      title="选择用户类型"
    >
      <p>
        托运人为<span style="color: red">个人认证</span>
        时注册信息包括姓名，手机号码，注册完成后需要完成实名认证并经平台管理员审核通过后才能发布货源信息。
      </p>
      <div style="margin: 20px 0"></div>
      <p>
        托运人为
        <span style="color: red">企业认证</span
        >，需要认证的的信息包括：公司名称，统一社会信用代码，法人姓名及身份证号，联系人，联系方式，通讯地址等信息，并且需要上传法人的身份证件照片，联系人的身份证件照片，企业的营业执照扫描件。
      </p>
      <div style="margin-top: 20px">
        <span>
          <Button
            size="default"
            :class="personals ? 'but-left' : ''"
            style="margin-left: 10px"
            @click="personalsbuts"
            >个人认证</Button
          >

          <Button
            size="default"
            :class="enterprises ? 'but-left' : ''"
            style="margin-left: 10px"
            @click="enterprisesbuts"
            >企业认证</Button
          ></span
        >
      </div>
      <div slot="footer">
        <Button @click="authenticationChoice" class="but-left">去认证</Button>
      </div>
    </Modal> -->
    <!-- 弹框 -->
    <Modal
      class="RuleLis"
      v-model="Ruleimod"
      :title="Ruletitle"
      width="50%"
      height="500"
    >
      <iframe
        style="border: 0"
        :src="this.htmls"
        height="540"
        width="100%"
        name="demo"
        scrolling="auto"
        sandbox="allow-same-origin"
      ></iframe>
      <div slot="footer">
        <Button @click="Ruleimod = false">取消</Button>
        <Button type="primary" @click="Ruleimod = false">确定</Button>
      </div>
    </Modal>
    <check-password ref="checkPassMobile" @on-success="checkSuccessMobile" />
    <check-password ref="checkPassEmail" @on-success="checkSuccessEmail" />
    <resetPassword ref="resetPass" @on-success="resetPasswords" />
  </div>
</template>

<script>
import {
  userInfo,
  userInfoEdit,
  // unRelate,
  // githubLogin,
  // qqLogin,
  // weiboLogin,
  // wechatLogin,
  // dingdingLogin,
  // workwechatLogin,
  sendEditEmail,
  editEmail,
  sendEditMobileSms,
  changeMobile,
  getProvinceData,
  getAreaCityList,
  sendRegistSms, //验证码
  initCaptcha, //图形验证码
  drawCodeImage,
} from "@/api/index";

import { validateMobile } from "@/libs/validate";
import uploadPicThumb from "@/views/my-components/freight/upload-pic-thumb";
import checkPassword from "@/views/my-components/freight/check-password";
import resetPassword from "@/views/my-components/freight/reset-password";
import Cookies from "js-cookie";
// import messageVue from "../message/message.vue";
import { getStore, setStore } from "@/libs/storage";
// 修改密码
import SetPassword from "@/views/my-components/freight/set-password";
import { changePass } from "@/api/index";
import CountDownButton from "@/views/my-components/freight/count-down-button";
// // // // // // // // // // // // // // // // // //
import {
  getCompanyLicenseInfo,
  getIdCarDInfo,
  saveIdCardInfo, //实名认证
  saveCompanyLicenseInfo, //企业认证
  getCompanyEnterprise, //获取企业信息
} from "@/api/user";
import {
  getPayWallet, //钱包
  userInfoVo, //货主信息
  updatepayPassword, //设置支付密码
  sendPayPasswordSms, //设置支付密码获取验证码
  // sendEditMobileSms, // 发送修改手机短信验证码
  modifypayPassword, //修改支付密码
  forgetPassword, //重置支付密码
  sendForgetPasswordSms, //忘记支付密码获取验证码
} from "@/api/ownerEnd/waybillAdmin";
import * as imageConversion from "image-conversion";
import axios from "axios";
import { uploadIdCardPic, upLoadCompanyLicense, uploadPic } from "@/api/index";
export default {
  components: {
    uploadPicThumb,
    checkPassword,
    CountDownButton,
    SetPassword,
    resetPassword, //重置密码
  },
  name: "ownspace_index",
  data() {
    const valideRePassword = (rule, value, callback) => {
      if (value !== this.editPasswordForm.newPass) {
        callback(new Error("两次输入密码不一致"));
      } else {
        callback();
      }
    };
    return {
      Ruletitle: "隐私协议",
      Ruleimod: false,
      htmls: "",

      saveLogins: true,
      spinShow: false,
      uploadPic: uploadPic,
      personals: true,
      enterprises: false,
      selectUserType: false, //选择用户类型
      authenticationRadio: "个人认证", //选择用户类型
      activeName: "基本信息",
      area: 86,
      messageOpen: 1,
      avatarImg: "",
      userForm: {
        id: "",
        avatar: "",
        username: "",
        sex: "",
        mobile: "",
        email: "",
        status: "",
        type: "",
        typeTxt: "",
        address: [],
        addressSelection: [],
      },
      header: {
        accessToken: getStore("accessToken"),
      },
      accessToken: getStore("accessToken"),
      mobileEditForm: {
        mobile: "",
        code: "",
        imgCode: "",
      },
      emailEditForm: {
        email: "",
        code: "",
      },
      AddressData: [],
      addressAddress: [],
      codeError: "",
      initPhone: "",
      initEmail: "",
      saveLoading: false,
      sending: false,
      getSms: "获取验证码",
      canSendMobileCode: true, // 是否可点获取验证码
      checkCodeLoading: false,
      checkPassLoading: false,
      editEmailLoading: false,
      mobileEditValidate: {
        mobile: [
          { required: true, message: "请输入手机号码" },
          { validator: validateMobile },
        ],
        imgCode: [
          {
            required: true,
            message: "验证码不能为空",
            trigger: "blur",
          },
        ],
        code: [
          {
            required: true,
            message: "验证码不能为空",
            trigger: "blur",
          },
        ],
      },
      emailEditValidate: {
        email: [
          { required: true, message: "请输入邮箱地址" },
          { type: "email", message: "邮箱格式不正确" },
        ],
      },
      editMobileVisible: false, // 显示填写验证码box
      editEmailVisible: false,
      canSendEditEmail: true,
      relate: {},
      jumping: false,
      currMenu: "基本信息",
      dictSex: this.$store.state.dict.sex,

      // 修改密码
      editPasswordVisible: false,
      savePassLoading: false,
      editPasswordForm: {
        oldPass: "",
        newPass: "",
        rePass: "",
      },
      strength: "",
      passwordValidate: {
        oldPass: [
          {
            required: true,
            message: "请输入原密码",
            trigger: "blur",
          },
        ],
        newPass: [
          {
            required: true,
            message: "请输入新密码",
            trigger: "blur",
          },
          {
            min: 6,
            message: "请至少输入6个字符，且必须包含数字字母",
            trigger: "blur",
          },
          {
            max: 32,
            message: "最多输入32个字符",
            trigger: "blur",
          },
        ],
        rePass: [
          {
            required: true,
            message: "请再次输入新密码",
            trigger: "blur",
          },
          {
            validator: valideRePassword,
            trigger: "blur",
          },
        ],
      },
      ////////////////////////  ////////////////////////  ////////////////////////
      // 图片验证码
      captchaId: "",
      captchaImg: "",
      loadingCaptcha: true,
      imgCodeError: "", //图片校验
      paymentPasswordBut: "设置",
      paymentPasswordTitle: "支付密码",
      paymentPasswordVisible: false, //  支付密码弹框
      preservationLoading: false,
      getSms: "获取验证码",
      labelPassword: "支付密码",
      placeholderPassword: "请输入支付密码",
      confLabelPassword: "确认密码",
      conLaceholderPassword: "请输入确认密码",
      butVerificationCode: true, //发送验证码
      //支付密码
      paymentPasswordForm: {
        mobile: "",
        idNum: "",
        password: "",
        confirmpassword: "",
        code: "",
      },
      paymentPasswordRules: {
        mobile: [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        idNum: [
          {
            required: true,
            message: "请输入身份证号",
            trigger: "blur",
          },
        ],
        password: [
          {
            required: true,
            message: "请输入密码",
            trigger: "blur",
          },
        ],
        confirmpassword: [
          {
            required: true,
            message: "请次输入确认密码",
            trigger: "blur",
          },
        ],
        code: [
          {
            required: true,
            message: "请输入验证码",
            trigger: "blur",
          },
        ],
      },

      userCompanyInfoData: {}, // 货主信息
      userCompanyWalletData: {}, // 获取钱包
      personalAuthentication: false,
      enterpriseCrtification: false,
      uploadIdCardPic: uploadIdCardPic,
      upLoadCompanyLicense: upLoadCompanyLicense,
      goodsVisible: false,
      loadinLicenseInfo: false,
      loadingsubmi: false,
      idCardIdForm: {
        userId: "",
        name: "", //名字
        num: "", //身份证号
        address: "", //居住地址
        birth: "", //生日
        sex: "", //性别
        nationality: "", //籍贯
        startDate: "", //身份证开始有效期
        endDate: "", //身份证结束有效期
        issue: "", //发证机关
        idCardFontPicFileId: "", //身份证正面照ID
        idCardBackPicFileId: "", //身份证背面照ID
        // holdIdCardFileId: "", //手持身份证照片ID
        contactPhone: "", //联系人电话
      },
      companyLicenseForm: {
        userId: "",
        companyName: "", //公司名称
        companyUserName: "", //法人
        certNo: "", //公司统一社会信用代码
        companyPhone: "", //公司注册电话
        street: "", //通讯地址
        companyPhone: "", //法人电话
        bankName: "", //开户行
        bankCode: "", //开户行账号
        type: "", //公司类型
        capital: "", //注册资金
        business: "", //经营范围
        startDate: "", //注册时间
        endDate: "", //截止日期
        companyLicenseFileId: "", //公司营业执照图片地址
        authorizationId: "", //委托授权书
        //联系人
        contactPhone: "", //联系人 --- 电话
        contactNum: "", //联系人 ---  身份证号
        contactName: "", //联系人 --- 姓名
        contactAddress: "", //联系人 --- 地址
        contactBirth: "", //联系人 --- 生日
        contactSex: "", //联系人 --- 性别
        contactNationality: "", //联系人 ---  民族
        contactStartDate: "", //联系人 --- 身份证起始日期
        contactEndDate: "", //联系人 --- 身份证结束日期
        contactIssue: "", //联系人 --- 签发机关
        contactIdCardFontPicFileId: "", //联系人 --- 身份证前置照片地址
        contactIdCardBackPicFileId: "", //联系人 --- 身份证后置照片地址
        // contactHoldIdCardFileId: "", //联系人 --- 手持身份证照片ID
      },
      companyForm: {
        companyName: [
          { required: true, message: "请输入公司名称", trigger: "blur" },
        ],
        companyUserName: [
          { required: true, message: "请输入法定代表人", trigger: "blur" },
        ],
        street: [
          { required: true, message: "请输入通讯地址", trigger: "blur" },
        ],
        companyPhone: [
          { required: true, message: "请输入法人电话", trigger: "blur" },
        ],
        // companyPhone: [
        //   { required: true, message: "请输入注册电话", trigger: "blur" },
        // ],
        // bankName: [
        //   { required: true, message: "请输入开户银行", trigger: "blur" },
        // ],
        // bankCode: [
        //   { required: true, message: "请输入银行账号", trigger: "blur" },
        // ],
        certNo: [
          {
            required: true,
            message: "请输入统一社会信用代码",
            trigger: "blur",
          },
        ],
        // type: [{ required: true, message: "请输入公司类型", trigger: "blur" }],
        contactName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],
        contactPhone: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
        ],
        contactEndDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        contactNum: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
        ],

        legalpersonName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
        ],

        legalpersonEndDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        legalpersonNum: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
        ],
      },
      progressBusinessLicen: false, // 营业执照
      progressCardBack: false, // 个人认证 身份证反面
      progressFlagnum: false, // 个人认证 身份证正面
      personalIDCard: false, // 个人认证 手拿身份证
      personalIDCardard: false,

      progressFront: false, // 联系人信息 身份证正面
      progressReverse: false, // 联系人信息 身份证反面
      handHeldProgress: false, //手持身份证联系人

      corporateFront: false, // 法人信息： 身份证正面
      corporateReverse: false, // 法人信息： 身份证反面
      progressAgreement: false, //授权协议书
      handHeldCorporate: false, //手持身份证法人

      idCardFontPicFileUrl: "", // 个人认证 身份证正面
      idCardBackPicFileUrl: "", // 个人认证 身份证反面
      // holdIdCardFileId: "", //手持身份个人认证

      enterpriseIdCardFontPicFileUrl: "", // 联系人信息 身份证正面
      enterprIseidCardBackPicFileUrl: "", // 联系人信息 身份证反面
      // handHeldProgressIdCard: "", //手持身份证联系人

      corporateidCardFontPicFileUrl: "", // 法人信息： 身份证正面
      corporateidCardBackPicFileUrl: "", // 法人信息： 身份证反面
      // personalIDCardUrl: "", // 法人证 手拿身份证

      companyPicFileUrl: "", // 营业执照
      agreementUrl: "", //授权协议书

      // 表单验证规则
      idCardBackPicFileList: [],
      formValidate: {
        name: [{ required: true, message: "请输入真实姓名", trigger: "blur" }],
        num: [{ required: true, message: "请输入身份证号", trigger: "blur" }],
        birth: [{ required: true, message: "请输入出生日期", trigger: "blur" }],
        sex: [{ required: true, message: "请输入性别", trigger: "blur" }],
        startDate: [
          { required: true, message: "请输入开始日期", trigger: "blur" },
        ],
        endDate: [
          { required: true, message: "请输入身份有效期", trigger: "blur" },
        ],
        address: [
          { required: true, message: "请输入家庭地址", trigger: "blur" },
        ],
        contactsName: [
          { required: true, message: "请输入联系人姓名", trigger: "blur" },
        ],
        contactPhone: [
          { required: true, message: "请输入联系人电话", trigger: "blur" },
        ],
      },
      load: 0,
      imobile: "",
    };
  },

  methods: {
    idCardIdFormEndDate(val) {
      this.idCardIdForm.endDate = val;
    },
    companylegalpersonEndDate(val) {
      this.companyLicenseForm.legalpersonEndDate = val;
    },
    companyLicenseFormEndDate(val) {
      this.companyLicenseForm.contactEndDate = val;
    },
    personalsbuts() {
      this.personals = true;
      this.authenticationRadio = "个人认证";
      this.enterprises = false;
    },
    enterprisesbuts() {
      this.enterprises = true;
      this.authenticationRadio = "企业认证";
      this.personals = false;
    },
    // 获取卸货省份数据
    getProvinceDataList() {
      let fn = () => {
        getProvinceData().then((res) => {
          if (res.code == 200) {
            res.result.forEach(function (e) {
              e.level = 1;
              e.label = e.provinceName;
              e.pid = e.provinceCode;
              e.value = e.provinceCode;
              e.loading = false;
              e.children = [];
            });
            this.AddressData = res.result;
          } else {
            this.$Message.error(res.message);
          }
        });
      };
      fn();
    },
    //搜索装货详细地址
    addLoadingProvinceloadData(item, callback) {
      item.loading = true;
      getAreaCityList({ code: item.value, type: item.level }).then((res) => {
        item.loading = false;
        if (res.code == 200) {
          res.result.forEach(function (e) {
            if (e.level != 3) {
              e.level = e.level;
              e.label = e.label;
              e.pid = e.pid;
              e.value = e.value;
              e.loading = false;
              e.children = [];
            } else {
              e.value = e.value;
              e.label = e.label;
            }
          });
          item.children = res.result;
          callback();
        } else {
          this.$Message.error(res.message);
        }
      });
    },
    // 搜索卸货详细地址
    addProvinceloadData(item, callback) {
      item.loading = true;
      getAreaCityList({ code: item.value, type: item.level }).then((res) => {
        item.loading = false;
        if (res.code == 200) {
          res.result.forEach(function (e) {
            if (e.level != 3) {
              e.level = e.level;
              e.label = e.label;
              e.pid = e.pid;
              e.value = e.value;
              e.loading = false;
              e.children = [];
            } else {
              e.value = e.value;
              e.label = e.label;
            }
          });
          item.children = res.result;
          callback();
        } else {
          this.$Message.error(res.message);
        }
      });
    },
    getStartArea(value, selectedData) {
      if (value.length == 3) {
        this.userForm.address = value;
      }
    },
    init() {
      // 基本信息
      this.essentialInformation();
      // 获取钱包
      //   this.getUserCompanyWalletData();

      let v = JSON.parse(Cookies.get("userInfo"));
      // 转换null为""
      for (let attr in v) {
        if (v[attr] == null) {
          v[attr] = "";
        }
      }
      let str = JSON.stringify(v);
      let userInfo = JSON.parse(str);
      this.userForm = userInfo;
      this.initPhone = userInfo.mobile;
      this.mobileEditForm.mobile = userInfo.mobile;
      this.initEmail = userInfo.email;
      this.emailEditForm.email = userInfo.email;
      if (this.userForm.type == 0) {
        this.userForm.typeTxt = "普通用户";
      } else if (this.userForm.type == 1) {
        this.userForm.typeTxt = "管理员";
      }
      this.userForm.addressSelection = userInfo.address.split(",");

      // relatedInfo(userInfo.username).then((res) => {
      //   if (res.success) {
      //     this.relate = res.result;
      //   } else {
      //     this.$Message.error("加载绑定第三方账号信息失败");
      //   }
      // });
      let messageOpen = this.getStore("messageOpen");
      if (
        messageOpen != "" &&
        messageOpen != undefined &&
        messageOpen != null
      ) {
        this.messageOpen = Number(messageOpen);
      } else {
        this.setStore("messageOpen", 1);
      }
    },
    // 修改密码
    changePass() {
      this.$refs.editPasswordForm.resetFields();
      this.editPasswordVisible = true;
    },
    // 设置支付密码
    setPasswords() {
      this.$refs.paymentPasswordForm.resetFields();
      this.butVerificationCode = true;
      this.$nextTick(() => {
        this.butVerificationCode = true;
      });
      this.paymentPasswordForm.code = "";
      this.paymentPasswordForm.idNum = "";
      this.paymentPasswordTitle = "设置支付密码";
      this.paymentPasswordVisible = true;
      this.paymentPasswordBut = "设置";

      this.labelPassword = "支付密码";
      this.placeholderPassword = "请输入支付密码";
      this.confLabelPassword = "确认密码";
      this.conLaceholderPassword = "请输入确认密码";
      this.paymentPasswordForm.mobile = this.userForm.mobile;
    },
    // 重置支付密码
    resetPassword() {
      this.$refs.resetPass.show();
      this.$refs.paymentPasswordForm.resetFields();
      this.paymentPasswordForm.code = "";
      this.paymentPasswordForm.idNum = "";
    },
    // 重置支付密码
    resetPasswords() {
      this.$refs.paymentPasswordForm.resetFields();
      this.paymentPasswordForm.code = "";
      this.paymentPasswordForm.idNum = "";
      this.butVerificationCode = true;
      this.$nextTick(() => {
        this.butVerificationCode = true;
      });
      this.paymentPasswordVisible = true;
      this.paymentPasswordTitle = "重置支付密码";
      this.paymentPasswordBut = "重置";

      this.labelPassword = "新密码";
      this.placeholderPassword = "请输入新的密码";
      this.confLabelPassword = "确认密码";
      this.conLaceholderPassword = "请输入确认密码";
      this.paymentPasswordForm.mobile = this.userForm.mobile;
    },

    // 修改支付密码
    editPasswords() {
      this.$refs.paymentPasswordForm.resetFields();
      this.paymentPasswordForm.code = "";
      this.butVerificationCode = true;
      this.$nextTick(() => {
        this.butVerificationCode = true;
      });
      this.paymentPasswordTitle = "修改支付密码";
      this.paymentPasswordVisible = true;
      this.paymentPasswordBut = "修改";

      this.labelPassword = "当前密码";
      this.placeholderPassword = "请输入当前支付密码";
      this.confLabelPassword = "新密码";
      this.conLaceholderPassword = "请输入新的支付密码";
      this.paymentPasswordForm.mobile = this.userForm.mobile;
    },
    // 支付密码
    changePaymentPass(v, grade, strength) {
      this.strength = strength;
    },
    // 保存支付密码
    preservationPassword() {
      this.$refs.paymentPasswordForm.validate((valid) => {
        if (valid) {
          if (this.paymentPasswordForm.code == "") {
            return this.$Message.warning("请输入验证码");
          }
          if (this.paymentPasswordTitle == "设置支付密码") {
            if (
              this.paymentPasswordForm.password !=
              this.paymentPasswordForm.confirmpassword
            ) {
              return this.$Message.warning("两次输入密码不一致");
            }
            this.preservationLoading = true;
            updatepayPassword(this.paymentPasswordForm).then((res) => {
              this.preservationLoading = false;
              if (res.code == 200) {
                //  this.getUserCompanyWalletData();
                this.paymentPasswordVisible = false;
                this.$Message.success("支付密码设置成功");
              } else {
                this.$Message.error(res.message);
              }
            });
          } else if (this.paymentPasswordTitle == "修改支付密码") {
            let data = {
              mobile: this.paymentPasswordForm.mobile,
              password: this.paymentPasswordForm.password,
              originalpassword: this.paymentPasswordForm.confirmpassword,
              code: this.paymentPasswordForm.code,
            };
            this.preservationLoading = true;
            modifypayPassword(data).then((res) => {
              this.preservationLoading = false;
              if (res.code == 200) {
                // this.getUserCompanyWalletData();
                this.paymentPasswordVisible = false;
                this.$Message.success("支付密码设置成功");
              } else {
                this.$Message.error(res.message);
              }
            });
          } else if (this.paymentPasswordTitle == "重置支付密码") {
            if (
              this.paymentPasswordForm.password !=
              this.paymentPasswordForm.confirmpassword
            ) {
              return this.$Message.warning("两次输入密码不一致");
            }
            let data = {
              idNum: this.paymentPasswordForm.idNum,
              password: this.paymentPasswordForm.password,
              confirmpassword: this.paymentPasswordForm.confirmpassword,
              code: this.paymentPasswordForm.code,
            };
            this.preservationLoading = true;
            forgetPassword(data).then((res) => {
              this.preservationLoading = false;
              if (res.code == 200) {
                //  this.getUserCompanyWalletData();
                this.paymentPasswordVisible = false;
                this.$Message.success("支付密码设置成功");
              } else {
                this.$Message.error(res.message);
              }
            });
          }
        }
      });
    },
    // 验证码
    checkVaptcha() {
      this.$refs.paymentPasswordForm.validate((valid) => {
        if (valid) {
          // 验证成功 发送验证码
          this.sendSmsCode();
        }
      });
    },
    // 验证成功 发送验证码
    sendSmsCode() {
      if (
        this.paymentPasswordTitle == "设置支付密码" ||
        this.paymentPasswordTitle == "修改支付密码"
      ) {
        this.sending = true;
        this.getSms = "发送中";
        sendPayPasswordSms().then((res) => {
          this.getSms = "获取验证码";
          this.sending = false;
          if (res.success) {
            this.$Message.success("发送短信验证码成功");
            // 开始倒计时
            this.$refs.countDown.startCountDown();
          }
        });
      } else {
        sendForgetPasswordSms().then((res) => {
          this.getSms = "获取验证码";
          this.sending = false;
          if (res.success) {
            this.$Message.success("发送短信验证码成功");
            // 开始倒计时
            this.$refs.countDown.startCountDown();
          }
        });
      }
    },
    // 切换
    changeMenu(v) {
      this.currMenu = v;
      if (v == "基本信息") {
        this.essentialInformation(); // 基本信息
      } else if (v == "安全设置") {
        //  this.getUserCompanyWalletData(); // 获取钱包
      } else if (v == "个人认证") {
        // 货主认证信息
        this.getOwnerCertification();
        // 货主信息
        this.getUserCompanyInfoData();
      } else if (v == "企业认证") {
        // 企业认证信息
        this.getCompanyLicense();
        //货主信息
        this.getUserCompanyInfoData();
      }
    },
    toRelateGithub() {
      this.jumping = true;
      githubLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    toRelateQQ() {
      this.jumping = true;
      qqLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    toRelateWeibo() {
      this.jumping = true;
      weiboLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    toRelateWechat() {
      this.jumping = true;
      wechatLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    toRelateDingding() {
      this.jumping = true;
      dingdingLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    toRelateWorkwechat() {
      this.jumping = true;
      workwechatLogin().then((res) => {
        if (res.success) {
          window.location.href = res.result;
        } else {
          this.jumping = false;
        }
      });
    },
    unRelateGithub() {
      this.$Modal.confirm({
        title: "确认解绑Github账号",
        content: "您确认要解除绑定 " + this.relate.githubUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.githubId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.github = false;
            }
          });
        },
      });
    },
    unRelateQQ() {
      this.$Modal.confirm({
        title: "确认解绑QQ账号",
        content: "您确认要解除绑定 " + this.relate.qqUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.qqId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.qq = false;
            }
          });
        },
      });
    },
    unRelateWeibo() {
      this.$Modal.confirm({
        title: "确认解绑微博账号",
        content: "您确认要解除绑定 " + this.relate.weiboUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.weiboId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.weibo = false;
            }
          });
        },
      });
    },
    unRelateWechat() {
      this.$Modal.confirm({
        title: "确认解绑微信账号",
        content: "您确认要解除绑定 " + this.relate.wechatUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.wechatId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.wechat = false;
            }
          });
        },
      });
    },
    unRelateDingding() {
      this.$Modal.confirm({
        title: "确认解绑钉钉账号",
        content: "您确认要解除绑定 " + this.relate.dingdingUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.dingdingId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.dingding = false;
            }
          });
        },
      });
    },
    unRelateWorkwechat() {
      this.$Modal.confirm({
        title: "确认解绑企业微信账号",
        content: "您确认要解除绑定 " + this.relate.workwechatUsername + " ?",
        loading: true,
        onOk: () => {
          let params = {
            ids: [this.relate.workwechatId],
          };
          unRelate(params).then((res) => {
            this.$Modal.remove();
            if (res.success) {
              this.$Message.success("操作成功");
              this.relate.workwechat = false;
            }
          });
        },
      });
    },
    showChangeMobile() {
      // this.mobileEditForm.mobile=""
      this.$refs.checkPassMobile.show();
      this.$refs.mobileEditForm.resetFields();
    },
    checkSuccessMobile() {
      this.editMobileVisible = true;
    },
    showChangeEmail() {
      this.$refs.checkPassEmail.show();
    },
    checkSuccessEmail() {
      this.editEmailVisible = true;
    },

    saveEdit() {
      this.saveLoading = true;
      if (typeof this.userForm.birth == "object") {
        this.userForm.birth = this.format(this.userForm.birth, "yyyy-MM-dd");
      }
      delete this.userForm.roles;
      userInfoEdit(this.userForm).then((res) => {
        this.saveLoading = false;
        if (res.success) {
          this.$Message.success("保存成功");
          // 获取用户信息
          userInfo().then((res) => {
            location.reload();
            if (res.success) {
              // 避免超过大小限制
              delete res.result.permissions;
              let roles = [];
              res.result.roles.forEach((e) => {
                roles.push(e.name);
              });
              localStorage.setItem("jurisdictionCargo", roles);
              delete res.result.roles;
              this.setStore("roles", roles);
              // 保存7天
              Cookies.set("userInfo", JSON.stringify(res.result), {
                expires: 7,
              });
              this.setStore("userInfo", res.result);
              this.$store.commit("setAvatarPath", res.result.avatar);
              // 加载菜单
              // util.initRouter(this);
              // this.$router.push({
              //   name: "home_index",
              // });
            } else {
              this.socialLogining = false;
              this.$Message.error("获取登录用户信息失败");
            }
          });
        }
      });
    },

    changeBirth(v) {
      this.userForm.birth = v;
    },
    cancelInputCodeBox() {
      this.editMobileVisible = false;
      this.userForm.mobile = this.initPhone;
    },
    cancelEditEmail() {
      this.editEmailVisible = false;
      this.emailEditForm.email = this.initEmail;
    },
    // 图片验证码
    getCaptchaImg() {
      this.loadingCaptcha = true;
      initCaptcha().then((res) => {
        this.loadingCaptcha = false;
        if (res.success) {
          this.captchaId = res.result;
          this.captchaImg = drawCodeImage + this.captchaId;
        }
      });
    },
    // 手机验证码
    sendEditMobileCode() {
      if (
        this.mobileEditForm.mobile != "" &&
        this.mobileEditForm.imgCode != ""
      ) {
        this.getSms = "发送中";
        this.sending = true;
        let data = {
          captchaId: this.captchaId,
          code: this.mobileEditForm.imgCode,
        };
        sendEditMobileSms(this.mobileEditForm.mobile, data).then((res) => {
           this.getSms = "获取验证码";
            this.sending = false;
            if (res.success) {
              this.$Message.success("发送验证码到手机成功，请注意查收");
              // 开始倒计时
              this.$refs.countDownMobile.startCountDown();
            }
        });
      } else {
        this.$Message.warning("请填写图片验证码");
      }
      // this.$refs["mobileEditForm"].validate((valid) => {
      //   if (valid) {
      //   }
      // });
    },
    // 修改手机号
    submitEditMobile() {
      this.$refs["mobileEditForm"].validate((valid) => {
        if (valid) {
          this.checkCodeLoading = true;
          changeMobile(this.mobileEditForm).then((res) => {
            this.checkCodeLoading = false;
            if (res.success) {
              this.$Message.success("修改成功");
              this.userForm.mobile = this.mobileEditForm.mobile;
              this.initPhone = this.mobileEditForm.mobile;
              this.getCaptchaImg();
              this.$Modal.success({
                title: "修改手机号成功",
                content: "修改手机号成功，需重新登录",
                onOk: () => {
                  this.$store.commit("logout", this);
                  this.$store.commit("clearOpenedSubmenu");
                  this.$router.push({
                    name: "login",
                  });
                },
              });
              this.editMobileVisible = false;
            }
          });
        }
      });
    },
    hasChangePhone() {
      if (this.mobileEditForm.mobile == this.initPhone) {
        this.canSendMobileCode = true;
      }
      this.canSendMobileCode = false;
      //  else {
      //   this.$refs["mobileEditForm"].validate((valid) => {
      //     if (valid) {
      //       this.canSendMobileCode = false;
      //     } else {
      //       this.canSendMobileCode = true;
      //     }
      //   });
      // }
    },
    hasChangeEmail() {
      if (this.emailEditForm.email == this.initEmail) {
        this.canSendEditEmail = true;
      } else {
        this.canSendEditEmail = false;
      }
    },
    sendVerifyEmail() {
      this.$refs["emailEditForm"].validate((valid) => {
        if (valid) {
          this.getSms = "发送中";
          this.sending = true;
          sendEditEmail(this.emailEditForm.email).then((res) => {
            this.getSms = "获取验证码";
            this.sending = false;
            if (res.success) {
              this.$Message.success("发送邮件验证码成功，请注意查收");
              // 开始倒计时
              this.$refs.countDownEmail.startCountDown();
            }
          });
        }
      });
    },
    submitEditEmail() {
      this.$refs["emailEditForm"].validate((valid) => {
        if (valid) {
          if (!this.emailEditForm.code) {
            this.codeError = "验证码不能为空";
            return;
          } else {
            this.codeError = "";
          }
          this.editEmailLoading = true;
          editEmail(this.emailEditForm).then((res) => {
            this.editEmailLoading = false;
            if (res.success) {
              this.initEmail = this.emailEditForm.email;
              this.userForm.email = this.emailEditForm.email;
              this.updateUserInfo();
              this.$Message.success("修改邮件成功");
              this.editEmailVisible = false;
            }
          });
        }
      });
    },
    updateUserInfo() {
      // 更新用户信息
      userInfo().then((res) => {
        if (res.success) {
          // 避免超过大小限制
          delete res.result.permissions;
          delete res.result.roles;
          if (this.getStore("saveLogin")) {
            // 保存7天
            Cookies.set("userInfo", JSON.stringify(res.result), {
              expires: 7,
            });
          } else {
            Cookies.set("userInfo", JSON.stringify(res.result));
          }
          this.setStore("userInfo", res.result);
        }
      });
    },
    changeMessage(v) {
      this.setStore("messageOpen", v);
    },
    // 修改密码
    changeInputPass(v, grade, strength) {
      this.strength = strength;
    },
    saveEditPass() {
      let params = {
        password: this.editPasswordForm.oldPass,
        newPass: this.editPasswordForm.newPass,
        passStrength: this.strength,
      };
      this.$refs["editPasswordForm"].validate((valid) => {
        if (valid) {
          this.savePassLoading = true;
          changePass(params).then((res) => {
            this.savePassLoading = false;
            if (res.success) {
              this.$Modal.success({
                title: "修改密码成功",
                content: "修改密码成功，需重新登录",
                onOk: () => {
                  this.$store.commit("logout", this);
                  this.$store.commit("clearOpenedSubmenu");
                  this.$router.push({
                    name: "login",
                  });
                },
              });
            }
          });
        }
      });
    },
    cancelEditPass() {
      this.$store.commit("removeTag", "change_pass");
      localStorage.pageOpenedList = JSON.stringify(
        this.$store.state.app.pageOpenedList
      );
      let lastPageName = "";
      let length = this.$store.state.app.pageOpenedList.length;
      if (length > 1) {
        lastPageName = this.$store.state.app.pageOpenedList[length - 1].name;
      } else {
        lastPageName = this.$store.state.app.pageOpenedList[0].name;
      }
      this.$router.push({
        name: lastPageName,
      });
    },
    //
    // // // v// // // // // // // // // // // // // // // // //
    // 基本信息
    essentialInformation() {
      userInfo().then((res) => {
        if (res.success) {
          // 避免超过大小限制

          delete res.result.permissions;
          let roles = [];
          res.result.roles.forEach((e) => {
            roles.push(e.name);
          });
          localStorage.setItem("jurisdictionCargo", roles);
          delete res.result.roles;
          this.setStore("roles", roles);
          // 保存7天
          Cookies.set("userInfo", JSON.stringify(res.result), {
            expires: 7,
          });
          this.setStore("userInfo", res.result);
          this.$store.commit("setAvatarPath", res.result.avatar);
          // 加载菜单
          // util.initRouter(this);
          // this.$router.push({
          //   name: "home_index",
          // });
        } else {
          this.socialLogining = false;
          this.$Message.error("获取登录用户信息失败");
        }
      });
    },
    // 获取钱包
    getUserCompanyWalletData() {
      getPayWallet().then((res) => {
        this.userCompanyWalletData = res.result;
      });
    },
    //货主信息
    getUserCompanyInfoData() {
      this.spinShow = true;
      userInfoVo().then((res) => {
        this.userCompanyInfoData = res.result.companyInfoVo;

        this.companyLicenseForm.contactPhone = res.result.mobile
          ? res.result.mobile
          : res.result.companyInfoVo.mobile;
        this.companyLicenseForm.companyPhone = res.result.mobile
          ? res.result.mobile
          : res.result.companyInfoVo.mobile;

        this.imobile = res.result.companyInfoVo.mobile;
        if (this.$route.query.authentication) {
          this.getCompanyLicense();
        }
        if (this.$route.query.authentication == 1) {
          this.spinShow = false;
          if (res.result.companyInfoVo.companyType == 1) {
            this.personalAuthentication = true;
            this.enterpriseCrtification = false;
            this.activeName = "个人认证";
            this.currMenu = "个人认证";
            this.getOwnerCertification();
          } else if (res.result.companyInfoVo.companyType == 2) {
            this.activeName = "企业认证";
            this.currMenu = "企业认证";
            this.personalAuthentication = false;
            this.enterpriseCrtification = true;
            this.getCompanyLicense();
            return;
          } else {
          }
        } else {
          this.spinShow = false;
          if (res.result.companyInfoVo.companyType == 1) {
            this.personalAuthentication = true;
          } else {
            this.enterpriseCrtification = true;
          }
        }
      });
    },
    // 企业认证信息
    getCompanyLicense() {
      getCompanyEnterprise({ userId: this.userCompanyInfoData.userId }).then(
        (res) => {
          if (res.success) {
            if (res.result != null) {
              // 企业信息
              this.companyLicenseForm.companyName =
                res.result.companyLicense.companyName;

              this.companyLicenseForm.companyUserName =
                res.result.companyLicense.companyUserName;

              this.companyLicenseForm.certNo = res.result.companyLicense.certNo;
              this.companyLicenseForm.companyPhone =
                res.result.companyLicense.companyPhone;

              this.companyLicenseForm.street = res.result.companyLicense.street;
              this.companyLicenseForm.bankName =
                res.result.companyLicense.bankName;

              this.companyLicenseForm.bankCode =
                res.result.companyLicense.bankCode;

              this.companyLicenseForm.type = res.result.companyLicense.type;
              this.companyLicenseForm.capital =
                res.result.companyLicense.capital;

              this.companyLicenseForm.business =
                res.result.companyLicense.business;

              this.companyLicenseForm.startDate =
                res.result.companyLicense.startDate;

              this.companyLicenseForm.endDate =
                res.result.companyLicense.endDate;

              this.companyLicenseForm.companyPhone =
                res.result.companyLicense.companyPhone;
              //联系人
              this.companyLicenseForm.contactPhone =
                res.result.contactsIdCard.contactPhone;

              this.companyLicenseForm.contactNum =
                res.result.contactsIdCard.num;

              this.companyLicenseForm.contactName =
                res.result.contactsIdCard.name;

              this.companyLicenseForm.contactAddress =
                res.result.contactsIdCard.address;

              this.companyLicenseForm.contactBirth =
                res.result.contactsIdCard.birth;

              this.companyLicenseForm.contactSex =
                res.result.contactsIdCard.sex;

              this.companyLicenseForm.contactNationality =
                res.result.contactsIdCard.nationality;

              this.companyLicenseForm.contactStartDate =
                res.result.contactsIdCard.startDate;

              this.companyLicenseForm.contactEndDate =
                res.result.contactsIdCard.endDate;

              this.companyLicenseForm.contactIssue =
                res.result.contactsIdCard.issue;

              // // 营业执照
              if (res.result.companyLicense.companyLicenseFileId != null) {
                this.companyLicenseForm.companyLicenseFileId =
                  res.result.companyLicense.companyLicenseFileId;

                this.companyPicFileUrl = this.imgUrl(
                  res.result.companyLicense.companyLicenseFileId
                );
              }
              //联系人信息 身份证正面
              if (res.result.contactsIdCard.idCardFontPicFileId != null) {
                this.companyLicenseForm.contactIdCardFontPicFileId =
                  res.result.contactsIdCard.idCardFontPicFileId;

                this.enterpriseIdCardFontPicFileUrl = this.imgUrl(
                  res.result.contactsIdCard.idCardFontPicFileId
                );
              }
              //联系人信息 身份证反面
              if (res.result.contactsIdCard.idCardBackPicFileId != null) {
                this.companyLicenseForm.contactIdCardBackPicFileId =
                  res.result.contactsIdCard.idCardBackPicFileId;

                this.enterprIseidCardBackPicFileUrl = this.imgUrl(
                  res.result.contactsIdCard.idCardBackPicFileId
                );
              }
            }
          } else {
            this.$Message.error(res.message);
          }
        }
      );
    },
    // 图片拼接
    imgUrl(val) {
      let url = "";
      if (val) {
        url = this.$baseUrl + val;
      }
      return url;
    },
    // 货主认证信息
    getOwnerCertification() {
      getIdCarDInfo({ userId: this.userCompanyInfoData.userId }).then((res) => {
        if (res.success) {
          if (res.result != null) {
            this.idCardIdForm = res.result;
            this.idCardIdForm.contactPhone = this.imobile;
            this.idCardIdForm.startDate =
              res.result.startDate == null
                ? ""
                : res.result.startDate.replaceAll("-", "");
            this.idCardIdForm.endDate =
              res.result.endDate == null
                ? ""
                : res.result.endDate.replaceAll("-", "");
            if (this.idCardIdForm.idCardFontPicFileId != null) {
              this.idCardFontPicFileUrl = this.imgUrl(
                this.idCardIdForm.idCardFontPicFileId
              );
            }
            if (this.idCardIdForm.idCardBackPicFileId != null) {
              this.idCardBackPicFileUrl = this.imgUrl(
                this.idCardIdForm.idCardBackPicFileId
              );
            }
            // if (this.idCardIdForm.holdIdCardFileId != null) {
            //   this.holdIdCardFileId = this.imgUrl(
            //     this.idCardIdForm.holdIdCardFileId
            //   );
            // }
          }
        } else {
          this.$Message.error(res.message);
        }
      });
    },
    useRegistration() {
      this.Ruletitle = "《" + "平台认证协议" + "》";
      this.Ruleimod = true;
      //
      this.htmls =
        this.$baseUrl +
        "/freight/system/authentication" +
        "?accessToken=" +
        this.accessToken +
        "&preview=true";
    },

    // 图片超出指定大小限制时的钩子
    handleMaxSize(file) {
      this.$Message.error("图片超出了最大存储限制");
    },
    //图片格式验证失败时的钩子
    handleFormatError(file) {
      this.$Message.error("图片格式错误,指定上传图片格式 jpg、jpeg、png");
    },
    //身份证正面进度条 个人认证
    cardFontProcess(event, file, fileList) {
      this.progressAll(event, 1);
    },
    //手持进度条 个人认证
    CardBackPro(event, file, fileList) {
      this.progressAll(event, 2);
    },
    // 身份证反面
    CardBackPross(event, file, fileList) {
      this.progressAll(event, 12);
    },
    // 营业执照 企业信息
    BusinessLicen(event, file, fileList) {
      this.progressAll(event, 3);
    },

    // 身份证正面 联系人信息
    enterprIseidCard(event, file, fileList) {
      this.progressAll(event, 4);
    },
    // 身份证反面 联系人信息
    enterprIseidCardf(event, file, fileList) {
      this.progressAll(event, 5);
    },

    // 身份证正面 法人信息
    corporateIseidCard(event, file, fileList) {
      this.progressAll(event, 6);
    },
    // 身份证反面 法人信息
    corporateIseidCardf(event, file, fileList) {
      this.progressAll(event, 7);
    },
    // 授权协议书
    AuthorizationAgreement(event, file, fileList) {
      this.progressAll(event, 8);
    },
    // 手持身份证联系人
    handHeldPro(event, file, fileList) {
      this.progressAll(event, 9);
    },
    // 手持身份证法人信息
    handHeldCardBackPro(event, file, fileList) {
      this.progressAll(event, 10);
    },
    // 手持身份证个人认证
    scardBackPro(event, file, fileList) {
      this.progressAll(event, 11);
    },

    //身份证正面进度条 个人认证
    cardFontHandleSuccess(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");

        this.idCardIdForm.name = res.result.name;
        this.idCardIdForm.num = res.result.num;
        this.idCardIdForm.address = res.result.address;
        this.idCardIdForm.nationality = res.result.nationality;
        this.idCardIdForm.sex = res.result.sex;
        this.idCardIdForm.birth = res.result.birth;
        this.idCardIdForm.idCardFontPicFileId = res.result.fileId;
        if (this.idCardIdForm.idCardFontPicFileId != null) {
          this.idCardFontPicFileUrl =
            this.$baseUrl +
            "/freight/file/view/" +
            this.idCardIdForm.idCardFontPicFileId +
            "?accessToken=" +
            this.accessToken +
            "&preview=true";
        }
      }
    },
    //身份证反面进度条 个人认证
    cardBackHandleSuccess(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");

        this.idCardIdForm.startDate = res.result.startDate;
      }
      //判断长期+99年
      if (res.result.endDate == "长期") {
        let dateNew = Number(res.result.startDate) + Number(990000);
        this.idCardIdForm.endDate = dateNew + "";
      } else {
        this.idCardIdForm.endDate = res.result.endDate;
      }

      this.idCardIdForm.issue = res.result.issue;
      this.idCardIdForm.idCardBackPicFileId = res.result.fileId;
      if (this.idCardIdForm.idCardBackPicFileId != null) {
        this.idCardBackPicFileUrl =
          this.$baseUrl +
          "/freight/file/view/" +
          this.idCardIdForm.idCardBackPicFileId +
          "?accessToken=" +
          this.accessToken +
          "&preview=true";
      }
    },
    //手持身份证
    personalIDSuccess(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
      }

      this.idCardIdForm.holdIdCardFileId = res.result;
      if (res.result != null) {
        this.holdIdCardFileId =
          this.$baseUrl +
          "/freight/file/view/" +
          res.result +
          "?accessToken=" +
          this.accessToken +
          "&preview=true";
      }
    },
    // 实名提交认证
    realNameAuthentication() {
      this.$refs.idCardIdForm.validate((valid) => {
        if (valid) {
          if (this.idCardFontPicFileUrl == "") {
            return this.$Message.error("请上传身份证正面");
          } else if (this.idCardBackPicFileUrl == "") {
            return this.$Message.error("请上传身份证背面");
          }
          // else if (this.holdIdCardFileId == "") {
          //   return this.$Message.error("请上传手持身份证照片");
          // }
          this.loadingsubmi = true;
          this.idCardIdForm.userId = this.userCompanyInfoData.userId;
          this.idCardIdForm.startDate = this.timeText(
            this.idCardIdForm.startDate
          );
          // if (!this.saveLogins) {
          //   this.$Message.success("请阅读并勾选平台认证协议");
          // }
          this.idCardIdForm.endDate = this.timeText(this.idCardIdForm.endDate);
          saveIdCardInfo(this.idCardIdForm).then((res) => {
            this.loadingsubmi = false;
            this.submitLoading = false;
            if (res.code == 200) {
              this.$Message.success("认证资料提交成功");
              location.reload();
            } else {
              this.$Message.error(res.message);
            }
          });
        }
      });
    },
    // 时间去横杠
    timeText(val) {
      let text = "";
      if (val) {
        let arr = val.split("");
        arr.forEach((item) => {
          if (item == "-") {
          } else {
            text += item;
          }
        });
      }
      return text;
    },
    // 企业提交认证
    enterpriseCertification() {
      this.$refs.companyLicenseForm.validate((valid) => {
        if (valid) {
          if (this.companyPicFileUrl == "") {
            return this.$Message.error("请上传营业执照");
          }
          if (this.enterpriseIdCardFontPicFileUrl == "") {
            return this.$Message.error("请上传联系人身份证正面");
          }
          if (this.enterprIseidCardBackPicFileUrl == "") {
            return this.$Message.error("请上传联系人身份证反面");
          }
          this.companyLicenseForm.userId = this.userCompanyInfoData.userId;

          this.companyLicenseForm.startDate = this.timeText(
            this.companyLicenseForm.startDate
          );
          this.companyLicenseForm.endDate = this.timeText(
            this.companyLicenseForm.endDate
          );
          this.companyLicenseForm.contactStartDate = this.timeText(
            this.companyLicenseForm.contactStartDate
          );
          this.companyLicenseForm.contactEndDate = this.timeText(
            this.companyLicenseForm.contactEndDate
          );
          this.companyLicenseForm.legalpersonEndDate = this.timeText(
            this.companyLicenseForm.legalpersonEndDate
          );
          // if (!this.saveLogins) {
          //   this.$Message.success("请阅读并勾选平台认证协议");
          // }
          for (var key in this.companyLicenseForm) {
            if (this.companyLicenseForm[key] == null) {
              this.companyLicenseForm[key] = "";
            }
          }
          this.$Modal.confirm({
            title: "确认提交",
            content: "确认提交企业认证资料吗？",
            loading: true,
            onOk: () => {
              saveCompanyLicenseInfo(this.companyLicenseForm).then((res) => {
                this.$Modal.remove();
                if (res.code == 200) {
                  this.$Message.success("认证资料提交成功");
                  location.reload();
                  this.activeName = "企业认证";
                  this.currMenu = "企业认证";
                } else {
                  this.$Message.error(res.message);
                }
              });
            },
          });
        }
      });
    },

    // 营业执照
    handleSuccess(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
        this.companyLicenseForm.companyName = res.result.companyName;
        this.companyLicenseForm.companyUserName = res.result.companyUserName;
        this.companyLicenseForm.certNo = res.result.certNo;
        // this.companyLicenseForm.companyPhone = res.result.companyPhone;
        this.companyLicenseForm.street = res.result.street;
        this.companyLicenseForm.bankName = res.result.bankName;
        this.companyLicenseForm.bankCode = res.result.bankCode;
        this.companyLicenseForm.type = res.result.type;
        this.companyLicenseForm.capital = res.result.capital;
        this.companyLicenseForm.business = res.result.business;
        this.companyLicenseForm.startDate = res.result.startDate;
        this.companyLicenseForm.endDate = res.result.endDate;
        this.companyLicenseForm.companyLicenseFileId = res.result.filepath;
        if (this.companyLicenseForm.companyLicenseFileId != null) {
          this.companyPicFileUrl =
            this.$baseUrl + this.companyLicenseForm.companyLicenseFileId;
        }
      }
    },
    // 联系人信息身份证正面
    enterpriseID(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");
        // this.form = { ...this.form, ...res.result };
        this.companyLicenseForm.contactName = res.result.name;
        this.companyLicenseForm.contactNum = res.result.num;
        this.companyLicenseForm.contactAddress = res.result.address;
        this.companyLicenseForm.contactNationality = res.result.nationality;
        this.companyLicenseForm.contactSex = res.result.sex;
        this.companyLicenseForm.contactBirth = res.result.birth;
        this.companyLicenseForm.contactIdCardFontPicFileId =
          res.result.filepath;
        if (this.companyLicenseForm.contactIdCardFontPicFileId != null) {
          this.enterpriseIdCardFontPicFileUrl =
            this.$baseUrl + this.companyLicenseForm.contactIdCardFontPicFileId;
        }
      }
    },
    // 联系人信息身份证反面
    reverseIDCard(res, file, fileList) {
      if (res.code == 500) {
        this.$Message.error(res.message);
        return;
      } else if (res.code == 200) {
        this.$Message.success("上传成功");

        this.companyLicenseForm.contactStartDate = res.result.startDate;
      }
      //判断长期+99年
      if (res.result.endDate == "长期") {
        let dateNew = Number(res.result.startDate) + Number(990000);
        this.companyLicenseForm.contactEndDate = dateNew + "";
      } else {
        this.companyLicenseForm.contactEndDate = res.result.endDate;
      }

      this.companyLicenseForm.contactIssue = res.result.issue;
      this.companyLicenseForm.contactIdCardBackPicFileId = res.result.filepath;

      if (this.companyLicenseForm.contactIdCardBackPicFileId != null) {
        this.enterprIseidCardBackPicFileUrl =
          this.$baseUrl + this.companyLicenseForm.contactIdCardBackPicFileId;
      }
    },

    // 查看图片
    showPic(v) {
      let image = new Image();
      image.src = v;
      let viewer = new Viewer(image, {
        hidden: function () {
          viewer.destroy();
        },
      });
      viewer.show();
    },
    // 删除图片
    handleRemove(file, num) {
      if (num == 1) {
        // 营业执照
        this.companyPicFileUrl = "";
      } else if (num == 2) {
        // 联系人信息身份证正面
        this.enterpriseIdCardFontPicFileUrl = "";
      } else if (num == 3) {
        // 联系人信息身份证反面
        this.enterprIseidCardBackPicFileUrl = "";
      } else if (num == 4) {
        // 法人信息身份证正面
        this.corporateidCardFontPicFileUrl = "";
      } else if (num == 5) {
        //法人信息身份证反面
        this.corporateidCardBackPicFileUrl = "";
      } else if (num == 6) {
        //委托授权书照片
        this.agreementUrl = "";
      } else if (num == 7) {
        //个人认证身份证反面
        this.idCardFontPicFileUrl = "";
      } else if (num == 8) {
        //个人认证身份证反面
        this.idCardBackPicFileUrl = "";
      }
    },
    progressAll(data, num) {
      if (num == 1) {
        //身份证正面进度条
        this.progressFlagnum = true; // 显示进度条
      } else if (num == 2) {
        //身份证反面进度条
        this.progressCardBack = true; // 显示进度条
      } else if (num == 3) {
        this.progressBusinessLicen = true;
      } else if (num == 4) {
        this.progressFront = true;
      } else if (num == 5) {
        this.progressReverse = true;
      } else if (num == 6) {
        this.corporateFront = true;
      } else if (num == 7) {
        this.corporateReverse = true;
      } else if (num == 8) {
        this.progressAgreement = true;
      } else if (num == 9) {
        this.handHeldProgress = true;
      } else if (num == 10) {
        this.handHeldCorporate = true;
      } else if (num == 11) {
        this.personalIDCard = true;
      } else if (num == 12) {
        this.personalIDCardard = true;
      }
      var CardBack = setTimeout(() => {
        this.load = parseInt(data.percent); // 动态获取文件上传进度
      }, 500); // 一秒后关闭进度条
      setTimeout(() => {
        if (this.load >= 100) {
          this.load = 100;
          setTimeout(() => {
            if (num == 1) {
              this.progressFlagnum = false; // 显示进度条
            } else if (num == 2) {
              this.progressCardBack = false; // 显示进度条
            } else if (num == 3) {
              this.progressBusinessLicen = false;
            } else if (num == 4) {
              this.progressFront = false;
            } else if (num == 5) {
              this.progressReverse = false;
            } else if (num == 6) {
              this.corporateFront = false;
            } else if (num == 7) {
              this.corporateReverse = false;
            } else if (num == 8) {
              this.progressAgreement = false;
            } else if (num == 9) {
              this.handHeldProgress = false;
            } else if (num == 10) {
              this.handHeldCorporate = false;
            } else if (num == 11) {
              this.personalIDCard = false;
            } else if (num == 12) {
              this.personalIDCardard = false;
            }
          }, 1000); // 一秒后关闭进度条
          clearTimeout(CardBack);
        }
      }, 501);
    },
    //压缩图片
    beforeUpload(file) {
      return new Promise((resolve, reject) => {
        // console.log("压缩前", file); // 压缩到400KB,大于400KB的图片都会进行压缩，小于则不会
        imageConversion.compressAccurately(file, 100).then((res) => {
          res = new File([res], file.name, {
            type: res.type,
            lastModified: Date.now(),
          });
          resolve(res);
        });
      });
    },
    //////////////////////////////////////////////////
    // 认证确定
    authenticationChoice() {
      // this.activeName = this.authenticationRadio;
      // this.currMenu = this.authenticationRadio;
      this.selectUserType = false;
      this.$router.push({
        name: "home_index",
        query: {
          authenticationRadio: this.authenticationRadio,
          authentication: 1,
        },
      });
    },
  },
  mounted() {
    this.getProvinceDataList();
    let type = this.$route.query.type;
    if (type == "social") {
      this.activeName = "第三方账号绑定";
      this.currMenu = "第三方账号绑定";
    }
    this.init();
    this.getCaptchaImg();
    // 货主信息
    this.getUserCompanyInfoData();
    if (this.$route.query.authentication) {
      this.activeName = "企业认证";
      this.currMenu = "企业认证";
    } else {
      this.activeName = "基本信息";
      this.currMenu = "基本信息";
    }
  },
};
</script>

<style lang="less">
.demo-upload-list-company {
  display: inline-block;
  width: 150px;
  height: 90px;
  text-align: center;
  line-height: 60px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-right: 4px;
}
.demo-upload-list-company img {
  width: 148px !important;
  height: 88.2px !important;
}
.demo-upload-list-company-cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
}
.demo-upload-list-company:hover .demo-upload-list-company-cover {
  display: block;
}
.demo-upload-list-company-cover i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  margin: 0 2px;
  line-height: 90px;
}

//
.check {
  &::before {
    content: "*";
    display: inline-block;
    margin-right: 2px;
    line-height: 1;
    font-family: SimSun;
    font-size: 14px;
    color: #ed4014;
  }
}
.checkdrag {
  &::before {
    content: "*";
    display: inline-block;
    margin-right: 2px;
    line-height: 1;
    font-family: SimSun;
    font-size: 14px;
    color: #ed4014;
    width: 5px;
    margin-left: 5px;
  }
}

.demo-uploadcss-compny {
  margin-top: -13px;
  width: 150px;
  height: 5px;
}
.adoptSubmitId {
  display: flex;
  justify-content: flex-end;
  margin-top: 347px;
}
.Cardokbtn-comy-comy {
  position: relative;
  bottom: 10px;
  left: 0;
  text-align: right;
}
.okbtn-comy {
  z-index: 99999;
  width: 100%;
  margin-top: -15px;
  // background-color: #f5f5f5;
  // border: 1px solid #cdcdcd;
  // height: 70px;
  // line-height: 70px;
}
.demo-drawer-footers-company {
  width: 100%;
  position: absolute;
  bottom: 0;
  left: 0;
  padding: 10px 16px;
  text-align: right;
  background-color: #f5f5f5;
  border: 1px solid #cdcdcd;
}
.check_font_message {
  font-size: 10px;
  color: #ed4014;
  font-weight: 600;

}
.check_font {
  font-size: 10px;
  font-weight: 600;
}
.certificationcss {
  width: 82%;
  position: relative;
  top: -40px;
  right: -99px;
}
.Modalcss {
  .ivu-modal-header {
    border-bottom: 0px !important;
  }
  .ivu-modal-footer {
    border-top: 0px !important;
  }
  .ivu-modal-header-inner {
    font-size: 16px !important;
    font-weight: 600 !important;
  }
}
.titles {
  font-size: 14px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.85);
  margin-left: 50px;
  margin-top: -20px;
  margin-bottom: 10px;
}
.company-bottom {
  display: flex;
  margin-top: 40px;
}
.line {
  margin: 20px 0;
  border-bottom: 1px solid #eee;
}
.titles1 {
  font-size: 14px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.85);
  margin-left: 18px;
  margin-top: -20px;
  margin-bottom: 10px;
}
.agreement1 {
  font-size: 12px;
  color: #515a6e;
  cursor: pointer;
  color: #2d8ce0;
  // border-bottom: 1px solid #2d8cf0;
  margin-top: 4px;
  margin-left: -10px;
}
.Upload-border {
  .ivu-upload-drag {
    border: 0px !important;
  }
}
</style>
<style lang="less" scoped>
.title-accon {
  padding-bottom: 5px;
  // font-size: 14px;
  // color: #8196c1;
  font-weight: 500;
}
</style>
<style lang="less" scoped>
@import "./accountUmberAdmin.less";
</style>